package com.yelobblog.yelobblog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yelobblog.yelobblog.domain.entity.user;
import org.apache.ibatis.annotations.*;

@Mapper
public interface userMapper extends BaseMapper<user> {
    @Select("SELECT * FROM user WHERE id = #{id}")
    user selectById(Integer id);

    @Insert("INSERT INTO FansTable (followersId, fansId) VALUES (#{FollowersId}, #{usersId})")
    void follow(Integer FollowersId, Integer usersId);

    @Delete("DELETE FROM FansTable WHERE followersId = #{id} AND fansId = #{selfId}")
    void unFollow(Integer id, Integer selfId);

    @Update("UPDATE user SET followCount = followCount + 1 WHERE id = #{id}")
    void addFollowCount(Integer id);
    @Update("UPDATE user SET fansCount = fansCount + 1 WHERE id = #{id}")
    void addFansCount(Integer id);
    @Update("UPDATE user SET followCount = followCount - 1 WHERE id = #{id}")
    void deleteFollowCount(Integer id);
    @Update("UPDATE user SET fansCount = fansCount - 1 WHERE id = #{id}")
    void deleteFansCount(Integer id);
}
